package
{
	import flash.net.NetConnection;
	import flash.net.Responder;

	public class Remoting extends NetConnection
	{
		public function Remoting(gatewayUrl:String, amfType:uint)
		{
			this.objectEncoding = amfType;
			this.connect(gatewayUrl);
		}

		public function respond(remoteMethod:String, onResultFun:*, onFaultFun:*, ... params):void
		{
			trace(remoteMethod);
			if (0 < params.length) {
				var parameters:Array = params;
				parameters.unshift(remoteMethod, new Responder(onResultFun, onFaultFun));
				this.call.apply(this, parameters);
			} else {
				this.call(remoteMethod, new Responder(onResultFun, onFaultFun));
			}
		}
	}
}
